public class Main2 {
    public static void main(String[] args) {

        Swimming s = new Swimming() {
            @Override
            public void swim() {
                System.out.println("老师游泳");
            }
        };
        go(s);

        Swimming s1 = () -> {
            System.out.println("学生游泳");
        };

        go(s1);

        go(new Swimming() {
            @Override
            public void swim() {
                System.out.println("小学生游泳");
            }
        });

        go(() -> {
            System.out.println("大学生游泳");
        });
    }

    public static void go(Swimming s){
        System.out.println("开始");
        s.swim();
        System.out.println("结束");
    }
}

@FunctionalInterface//一旦加上这个标志，就代表这个接口中只能有一个抽象方法
interface  Swimming{
    void swim();
}
